<template>
  <div class="PC" style="height: calc(100vh - 60px); overflow: hidden">
    <div class="staff-app-container">
      <div
        style="
          display: flex;
          border-radius: 20px;
          box-sizing: border-box;
          color: #9093b3;
          height: 100vh;
          justify-content: space-between;
        "
      >
        <div
          style="
            width: 140px;
            border-right: 1px solid #e7e7e7;
            height: 100vh;
            background-color: #f5f7fa;
          "
        >
          <div
            v-for="(item, index) in switchRoute"
            style="text-align: center; height: 40px; line-height: 40px; margin: 30px 0"
            :class="[item.id == selectIndex ? 'active' : '']"
            @click="tiao(item)"
            class="box"
          >
            {{ item.name }}
          </div>
        </div>
        <div style="width: calc(100% - 180px)">
          <div v-if="selectIndex == 0">
            <wu />
          </div>
          <div v-else-if="selectIndex == 1">
            <che />
          </div>
          <div v-else-if="selectIndex == 2">
            <hui />
          </div>
        </div>
      </div>
    </div>
  </div>
  <div
    class="move"
    style="
      padding-bottom: 60px;
      width: 100vw;
      height: calc(100vh - 60px);
      overflow-x: hidden;
    "
  >
    <div class="mobile-tabs">
      <div
        v-for="item in switchRoute"
        class="mobile-tab-item"
        @click="tiao(item)"
        :class="[item.id == selectIndex ? 'moveActive' : '']"
      >
        {{ item.name }}
        <div
          v-if="item.id == selectIndex"
          class="mobile-tab-indicator"
        ></div>
      </div>
    </div>
    <div class="mobile-content">
      <div v-if="selectIndex == 0">
        <wu />
      </div>
      <div v-else-if="selectIndex == 1">
        <che />
      </div>
      <div v-else-if="selectIndex == 2">
        <hui />
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { RouterView } from "vue-router";
import { onMounted } from "vue";

onMounted(() => {
  console.log("Staff App mounted");
  console.log("Current path:", window.location.pathname);
  console.log("Current hash:", window.location.hash);
});

import { ref } from "vue";
import { useRouter } from "vue-router";
import wu from "./views/wu.vue";
import che from "./views/che.vue";
import hui from "./views/hui.vue";
interface itemTS {
  name: string;
  id: number;
}
const router = useRouter();
const selectIndex = ref(0);
const switchRoute = ref<itemTS[]>([
  {
    id: 0,
    name: "物资管理",
  },
  {
    id: 1,
    name: "车辆管理",
  },
  {
    id: 2,
    name: "会议管理",
  },
]);
function tiao(item: itemTS) {
  selectIndex.value = item.id;
  console.log(selectIndex.value);
}
</script>

<style scoped>
.staff-app-container {
  width: 100%;
  height: 100%;
  padding: 10px;
}

.debug-info {
  background-color: #f0f0f0;
  padding: 5px;
  margin-bottom: 10px;
  font-size: 12px;
  color: #666;
}

.active {
  color: #203a64;
  transition: background-color 0.3s ease;
}

.box:hover {
  background-color: #f0f0f0; /* 滑过变浅灰，可自定义颜色 */
}

.moveActive {
  color: #263a63 !important;
}

/* 移动端样式 */
.mobile-tabs {
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: 50px;
  background-color: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  position: sticky;
  top: 0;
  z-index: 10;
}

.mobile-tab-item {
  font-size: 16px;
  font-weight: 800;
  color: #9b9cba;
  padding: 10px 0;
  position: relative;
  flex: 1;
  text-align: center;
  transition: all 0.3s ease;
}

.mobile-tab-indicator {
  width: 30px;
  border: 2px solid #9b9cba;
  margin: 0 auto;
  margin-top: 5px;
  transition: all 0.3s ease;
}

.mobile-content {
  padding: 10px;
  overflow-y: auto;
}

@media (max-width: 1000px) {
  .PC {
    display: none;
  }
  .move {
    display: block;
  }
}

@media (min-width: 1000px) {
  .PC {
    display: block;
  }
  .move {
    display: none;
  }
}

/* 移动端适配 */
@media (max-width: 768px) {
  .mobile-tabs {
    height: 45px;
  }
  
  .mobile-tab-item {
    font-size: 14px;
  }
  
  .mobile-tab-indicator {
    width: 25px;
  }
  
  .mobile-content {
    padding: 8px;
  }
}

@media (max-width: 480px) {
  .mobile-tabs {
    height: 40px;
  }
  
  .mobile-tab-item {
    font-size: 13px;
    font-weight: 600;
  }
  
  .mobile-tab-indicator {
    width: 20px;
    border-width: 1px;
  }
}
</style>
